/*
 * @Author: your name
 * @Date: 2021-11-13 14:51:12
 * @LastEditTime: 2021-11-13 15:33:35
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: /vue-form-json/src/mixins/emitter.js
 */
export default {
    methods: {
        dispatch(componentName, eventName, params) {
            let parent = this.$parent || this.$root;
            let name = parent.$options.name;
            while (parent && (!name || name !== componentName)) {
                parent = parent.$parent;
                if (parent) name = parent.$options.name;
            }
            if (parent) parent.$emit.apply(parent, [eventName].concat(params));
        }
    }
}
